package a.h;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.net.URL;

class r
  extends d
  implements mb.b_
{
  private JToggleButton n;
  private ed o;
  private Color p;
  private boolean q;
  private boolean r;
  private ob s;
  private String t;
  private static final int u = 32;
  private static final int v = 32;
  private int w = 4;
  
  public r(mc parammc, ob paramob)
  {
    super(parammc);
    a(parammc, paramob);
  }
  
  private void a(mc parammc, ob paramob)
  {
    int i = ec.t;
    boolean bool = ec.s;
    this.s = paramob;
    if (i == 0) {
      if (this.s == null)
      {
        if (i != 0) {
          break label62;
        }
        this.t = "No Image";
        if (!bool) {
          break label58;
        }
      }
    }
    this.t = this.s.b("IMAGE_OPTION_ITEM.NO_IMAGE");
    label58:
    label62:
    Object localObject1 = parammc.o();
    Object localObject2 = null;
    String str = null;
    if ((localObject1 != null) && ((i != 0) || (!parammc.r())))
    {
      if (i == 0) {
        if ((localObject1 instanceof ed))
        {
          localObject2 = ((ed)localObject1).a();
          URL localURL = ((ed)localObject1).b();
          if ((i != 0) || (localURL != null))
          {
            str = localURL.toString();
            break label195;
          }
          str = "";
          break label195;
        }
      }
      if (i == 0) {
        if ((localObject1 instanceof Image))
        {
          localObject2 = (Image)localObject1;
          break label195;
        }
      }
      if ((i != 0) || ((localObject1 instanceof URL))) {
        try
        {
          localObject2 = ImageIO.read((URL)localObject1);
          str = localObject1.toString();
        }
        catch (IOException localIOException) {}
      }
    }
    label195:
    if (localObject2 != null)
    {
      this.n = new JToggleButton(a((Image)localObject2));
      if (i != 0) {
        break label258;
      }
      if (str != null)
      {
        if (i != 0) {
          break label258;
        }
        this.n.setText(str);
        if (!bool) {}
      }
    }
    else
    {
      this.n = new JToggleButton();
    }
    if (localObject1 != null) {
      label258:
      if (!parammc.r()) {}
    } else {
      this.n.setText(this.t);
    }
    this.n.setMinimumSize(new Dimension(36, 32));
    this.n.setPreferredSize(new Dimension(36, 32));
    this.n.setHorizontalAlignment(10);
    this.n.setMargin(new Insets(this.w, 3 * this.w, this.w, 3 * this.w));
    this.p = this.n.getBackground();
    this.n.addActionListener(new ActionListener()
    {
      private final mc val$item;
      
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        r.this.a(this.val$item);
      }
    });
    this.r = false;
    a(localObject1);
    this.r = true;
    this.q = false;
    d(this.i.m());
    c(this.i.f());
  }
  
  private ImageIcon a(Image paramImage)
  {
    double d1 = paramImage.getWidth(null);
    int i = paramImage.getHeight(null);
    double d2 = d1 / i;
    int j = 32 - 2 * this.w;
    d1 = j * d2;
    return new ImageIcon(paramImage.getScaledInstance((int)d1, j, 2));
  }
  
  private void a(mc parammc)
  {
    int j = ec.t;
    int i = parammc.b().a().size();
    mb localmb = new mb(parammc, this.n, new Rectangle(this.n.getWidth(), this.n.getHeight()), this.s);
    localmb.a(this);
    if (j == 0) {
      if (i > 0)
      {
        JPopupMenu localJPopupMenu = localmb.a();
        localJPopupMenu.setSize(this.n.getWidth(), localJPopupMenu.getHeight());
        localJPopupMenu.show(this.n, 0, this.n.getHeight());
      }
    }
    if ((j != 0) || ((ec.s) && (((Boolean)parammc.c("ImageOptionItem.allowBrowse")).booleanValue()))) {
      localmb.a(null);
    }
  }
  
  public Object n()
  {
    return this.o;
  }
  
  public void a(Object paramObject)
  {
    int i = ec.t;
    boolean bool = ec.s;
    if (i == 0) {
      if (paramObject == null)
      {
        b();
        if ((i == 0) && (!bool)) {
          return;
        }
      }
    }
    if (i == 0) {
      if ((paramObject instanceof ed))
      {
        a((ed)paramObject);
        if ((i == 0) && (!bool)) {
          return;
        }
      }
    }
    if (i == 0) {
      if ((paramObject instanceof URL)) {
        try
        {
          BufferedImage localBufferedImage = ImageIO.read((URL)paramObject);
          a(new ed(localBufferedImage, (URL)paramObject));
        }
        catch (IOException localIOException)
        {
          if (i != 0) {}
        }
      }
    }
    if ((bool) && ((paramObject instanceof Image))) {
      a(new ed((Image)paramObject, null));
    }
  }
  
  public boolean o()
  {
    return this.n.isEnabled();
  }
  
  public void c(boolean paramBoolean)
  {
    boolean bool = this.n.isEnabled();
    if (ec.t == 0)
    {
      if (bool != paramBoolean) {
        this.n.setEnabled(paramBoolean);
      }
    }
    else {
      a(bool, paramBoolean);
    }
  }
  
  public boolean p()
  {
    return this.q;
  }
  
  public void d(boolean paramBoolean)
  {
    int i = ec.t;
    if ((i != 0) || (this.q != paramBoolean))
    {
      boolean bool = this.q;
      if (i == 0)
      {
        this.q = paramBoolean;
        if (paramBoolean)
        {
          this.n.setText("");
          this.n.setIcon(null);
          if (i != 0) {
            break label83;
          }
          this.n.setBackground(ic.a);
          if (!ec.s) {
            break label82;
          }
        }
      }
      this.n.setBackground(this.p);
      label82:
      label83:
      b(bool, paramBoolean);
    }
  }
  
  public JComponent f()
  {
    return this.n;
  }
  
  void a(ed paramed)
  {
    int i = ec.t;
    boolean bool = ec.s;
    ed localed = this.o;
    String str = this.n.getText();
    if ((i != 0) || (nb.a(localed, paramed)))
    {
      if (i == 0)
      {
        if (this.r) {
          try
          {
            b(e, localed, paramed);
          }
          catch (PropertyVetoException localPropertyVetoException)
          {
            this.n.setIcon(a(localed.a()));
            this.n.setText(str);
            return;
          }
        }
        if (i != 0) {}
      }
      else
      {
        if (paramed.c())
        {
          this.o = paramed;
          this.n.setIcon(null);
          this.n.setText(this.t);
          if (i != 0) {
            break label221;
          }
          if (!bool) {
            break label212;
          }
        }
        this.o = paramed;
      }
      Image localImage = paramed.a();
      this.n.setIcon(localImage == null ? null : a(localImage));
      URL localURL = paramed.b();
      if (i == 0)
      {
        if (localURL != null) {
          this.n.setText(localURL.toString());
        }
      }
      else
      {
        if (i != 0) {
          break label221;
        }
        if (!bool) {
          break label212;
        }
      }
      this.n.setText("");
      label212:
      if ((i != 0) || (this.r)) {
        label221:
        a(localed, paramed);
      }
    }
  }
  
  void b()
  {
    int i = ec.t;
    ed localed = this.o;
    String str = this.n.getText();
    if ((i != 0) || (nb.a(localed, null)))
    {
      if (i == 0)
      {
        if (this.r) {
          try
          {
            b(e, localed, null);
          }
          catch (PropertyVetoException localPropertyVetoException)
          {
            this.n.setIcon(a(localed.a()));
            this.n.setText(str);
            return;
          }
        }
        this.o = null;
        this.n.setIcon(null);
        this.n.setText(this.t);
      }
      if ((i != 0) || (this.r)) {
        a(localed, null);
      }
    }
  }
  
  void b(JPopupMenu paramJPopupMenu, Object paramObject)
  {
    a(paramObject);
    d(false);
    paramJPopupMenu.setVisible(false);
    this.n.setSelected(false);
  }
  
  public void a(JPopupMenu paramJPopupMenu, Object paramObject)
  {
    b(paramJPopupMenu, paramObject);
  }
  
  public void a()
  {
    this.n.setSelected(false);
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.h.r

 * JD-Core Version:    0.7.0.1

 */